package com.zhenlong.aop.service.impl;

import com.zhenlong.aop.Enum.OperLogEnum;
import com.zhenlong.aop.dao.SysLogDao;
import com.zhenlong.aop.dao.UserLogDao;
import com.zhenlong.aop.domain.SysLog;
import com.zhenlong.aop.domain.UserLog;
import com.zhenlong.aop.service.Myservice;
import com.zhenlong.aop.vo.User;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MyserviceImpl implements Myservice {
    @Autowired
    private UserLogDao userLogDao;
    @Autowired
    private SysLogDao sysLogDao;
    @Override
    public List<SysLog> queryAll(User user) throws Exception {

        if (user.getOperType().equals(OperLogEnum.QUERY.getName())){
            throw new RuntimeException("nihao");
        }




        return sysLogDao.queryAll();
    }

    @Override
    public void saveUserLog(User user) {
        UserLog userLog = new UserLog();
        BeanUtils.copyProperties(user,userLog);
        userLogDao.insert(userLog);
    }
}
